<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
<!--        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"

        >新增</el-button>-->
       <!-- v-hasPermi="['board:information:add']"-->
      </el-col>
    </el-row>
    <!-- gss-状态选择 -->
    <div class="allStatus">
      <div class="timeStatus">
         <p>时间：</p>
         <p v-for='(item,index) in timeStatusList' :key="index" @click="timeStatusChange(item.status)" :class="timeStatus==item.status?'active':''">{{item.text}}</p>
      </div>
      <div class="timeStatus">
         <p>状态：</p>
         <p v-for='(item,index) in statusList' :key="index" @click="statusChange(item.status)" :class="status==item.status?'active':''">{{item.text}}</p>
      </div>
         <div class="timeStatus">
             <p>来源：</p>
             <p v-for='(item,index) in originStatusList' :key="index"  @click="originStatusChange(item.status)" :class="originStatus==item.status?'active':''">{{item.text}}</p>
         </div>
       <div class="originStatus">
         <div class="timeStatus">
             <p>排序：</p>
             <p v-for='(item,index) in startTimeStatusList' :key="index"  @click="startTimeStatusChange(item.status)" :class="startStatus==item.status?'active':''">{{item.text}}</p>
         </div>
         <div class="listStatus">
           <span class="el-icon-plus" v-if="userPost!='commander'"  @click="handleAdd"></span>
           <span :class="pageShowStatus==true?'el-icon-s-fold':'el-icon-s-unfold'" @click="pageShowStatusChange"></span>
         </div>
      </div>
    </div>
    <!-- gss-状态选择 -->
    <!-- gss-页面切换 -->
    <el-row v-loading="loading" :gutter="24" v-if="!pageShowStatus" class="informationList">
      <div v-if="informationList && informationList.length > 0">
        <el-col :xs="12" :sm="6" :lg="4" v-for="(item,index) in informationList" :key="index" class="informationItem">
          <div   class="box">
           <p class="informationItemTitle" v-if="!(userPost == 'section_member' || userPost == 'section_chief')">
                 <b :title="item.taskTheme">{{item.taskTheme}}</b>
                  <el-tag v-if="item.taskStatus==1" type="success" effect="dark">待办</el-tag>
                  <el-tag v-if="item.taskStatus==2" type="warning" effect="dark">进行中</el-tag>
                  <el-tag v-if="item.taskStatus==3"  effect="dark">已完成</el-tag>
                  <el-tag v-if="item.taskStatus==4" type="danger" effect="dark">超期</el-tag>
             </p>
              <p class="informationItemTitle" v-if="userPost == 'section_member' || userPost == 'section_chief'">
                  <b :title="item.taskTheme">{{item.taskTheme}}</b>
                  <el-tag v-if="item.formStatus==1" type="success" effect="dark">待办</el-tag>
                  <el-tag v-if="item.formStatus==2" type="warning" effect="dark">进行中</el-tag>
                  <el-tag v-if="item.formStatus==3"  effect="dark">已完成</el-tag>
                  <el-tag v-if="item.formStatus==4" type="danger" effect="dark">超期</el-tag>
             </p>
           <p :title="parseTime(item.startDate, '{y}-{m}-{d}') +'至'+ parseTime(item.endDate, '{y}-{m}-{d}')">周期： {{ parseTime(item.startDate, '{y}-{m}-{d}') }} 至 {{ parseTime(item.endDate, '{y}-{m}-{d}') }}</p>
           <p :title='(item.taskObjectStationNum !=null && item.taskObjectStationNum!="")? item.firstStationName+"等"+item.taskObjectStationNum+"家企业"
          :item.twoJoinedName'>对象： {{(item.taskObjectStationNum !=null && item.taskObjectStationNum!="")? item.firstStationName+"等"+item.taskObjectStationNum+"家企业"
          :item.twoJoinedName}}</p>
           <p :title="item.taskDescribe">描述： {{item.taskDescribe}}</p>
           <p :title="item.deptName">发布机构：{{item.deptName}}</p>
            <p class="buttonColor">
                   <el-button
                     v-if="userPost != 'section_member'"
            size="mini"
            type="text"
            icon="el-icon-edit"
                     :disabled="isHandleDisable(item)"
            @click="handleUpdate(item)">{{userPost == 'director'?'详情':'执行'}}</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-document"
                @click="handleView(item)">{{'任务明细'}}</el-button>
            </p>
            </div>
        </el-col>
      </div>
      <div v-else>
        <div align="center" style="color: #8c939d;font-size: small;">暂无数据</div>
      </div>
    </el-row >
    <!-- gss-页面切换 -->
    <el-table v-if="pageShowStatus" v-loading="loading" :data="informationList" @selection-change="handleSelectionChange">
      <el-table-column label="任务主题" align="center" prop="taskTheme" />
      <el-table-column label="任务类型" align="center" prop="taskType"  :formatter="typeFormat"/>

      <el-table-column label="任务周期" align="center" prop="startDate" width="280">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }} 至 {{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="结束时间" align="center" prop="endDate" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->

<!--      <el-table-column label="发起部门" align="center" prop="deptName" />-->

<!--      <el-table-column label="发起人" align="center" prop="taskPublishUserName" />-->
      <el-table-column label="任务对象" align="center" prop="taskObjectIds" >
      <template slot-scope="scope">
        <span>{{(scope.row.taskObjectStationNum !=null && scope.row.taskObjectStationNum!="")? scope.row.firstStationName+"等"+scope.row.taskObjectStationNum+"家企业"
          :scope.row.twoJoinedName}}</span>
      </template>
      </el-table-column>
      <el-table-column label="任务状态" v-if="!(userPost == 'section_member' || userPost == 'section_chief')" align="center" prop="taskStatus" :formatter="statusFormat"/>
      <el-table-column label="任务状态" v-if="userPost == 'section_member' || userPost == 'section_chief'" align="center" prop="formStatus" :formatter="formStatusFormat"/>

      <el-table-column label="完成时间" v-if="!(userPost == 'section_member' || userPost == 'section_chief')" align="center" prop="completionTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.completionTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="完成时间" v-if="userPost == 'section_member' || userPost == 'section_chief'" align="center" prop="formCompletionTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.formCompletionTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-if="userPost != 'section_member'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            :disabled="isHandleDisable(scope.row)"
          >{{userPost == 'director'?'详情':'执行'}}</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="handleView(scope.row)"

          >{{'任务明细'}}</el-button>
         <!-- v-hasPermi="['board:information:edit']"-->
<!--          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['board:information:remove']"
          >删除</el-button>-->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
      :page-sizes="[18]"
    />

    <!-- 添加或修改主任务信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="600px" :before-close="handleDialogClose" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="任务主题" prop="taskTheme">
          <el-input v-model="form.taskTheme" placeholder="请输入任务主题" maxlength="30" :disabled="isActionDisable" show-word-limit/>
        </el-form-item>
        <el-form-item label="任务类型">
          <el-select v-model="form.taskType" placeholder="请选择任务类型" :disabled="isActionDisable" @change="changeView">
            <el-option
              v-for="dict in memberPublishType"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue">
            </el-option>
          </el-select>
        </el-form-item>
        <el-row :gutter="30">
          <el-col :span="10">
        <el-form-item label="任务周期" prop="startDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.startDate"
            type="date"
            value-format="yyyy-MM-dd" :disabled="isActionDisable"
            placeholder="选择开始时间">
          </el-date-picker>
        </el-form-item>
          </el-col>
          <el-col :span="10">
        <el-form-item label="----" prop="endDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.endDate"
            type="date"
            value-format="yyyy-MM-dd" :disabled="isActionDisable"
                          :picker-options="pickerOptions"
            placeholder="选择结束时间">
          </el-date-picker>
        </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="任务描述" prop="taskDescribe">
        <el-input v-model="form.taskDescribe" type="textarea" placeholder="请输入任务描述" maxlength="200" :disabled="isActionDisable" show-word-limit/>
      </el-form-item>
        <el-form-item label="任务对象" prop="taskObjectIds" v-if=" userPost == undefined || (userPost == 'director' || (userPost == 'section_chief' && taskTypeFlag == 2))">
          <el-button v-model="form.taskObjectIds" suffix-icon="el-icon-search" placeholder="点击选择"  @click="chooseObject">
            点击选择
          </el-button>
          <span class="selectComplainNumber" v-if="userPost == 'director' && taskTypeFlag !=3 && form.taskObjectAreasNum && form.taskObjectAreasNum !=''">已选择区域的企业数量：{{form.taskObjectAreasNum}}</span>
          <span class="selectComplainNumber" v-if="checkedCompanyIds.length && checkedCompanyIds.length!=0 && taskTypeFlag ==3 && userPost == 'director' ">已选择企业数量：{{checkedCompanyIds.length}}</span>
          <span class="selectComplainNumber" v-if="checkedCompanyIds.length && checkedCompanyIds.length!=0 && taskTypeFlag ==2 && userPost == 'section_chief' ">已选择企业数量：{{checkedCompanyIds.length}}</span>
        </el-form-item>
        <!--特定任务单独写一个按钮-->
        <el-form-item label="任务对象" prop="taskObjectIds" v-if=" ((userPost == 'section_chief'|| userPost == 'section_member') && taskTypeFlag == 3)">
          <el-button v-model="form.taskObjectIds" suffix-icon="el-icon-search" placeholder="点击选择"  @click="chooseSpecialObject">
            点击选择
          </el-button>
          <span class="selectComplainNumber" v-if="createByOwnFlag =='N' &&specialTaskForm.list&&specialTaskForm.list.length!=0 && taskTypeFlag ==3 ">已选择企业数量：{{specialTaskForm.list.length}}</span>
          <span class="selectComplainNumber" v-if="createByOwnFlag!='N' && checkedCompanyIds&&checkedCompanyIds.length!=0 && taskTypeFlag ==3 ">已选择企业数量：{{checkedCompanyIds.length}}</span>

        </el-form-item>

        <!--科长 选择规则模板-->
        <el-form-item label="规则模板" prop="ruleId" v-if="userPost == 'section_chief' && taskTypeFlag == 1 ">
          <el-select v-model="form.ruleId" placeholder="请选择规则模板" >
            <el-option
              v-for="dict in ruleDictionary"
              :key="dict.id"
              :label="dict.ruleTheme"
              :value="dict.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="内容" prop="templateId" v-if="(userPost == 'section_chief' && (taskTypeFlag == 1 || taskTypeFlag == 2))">
          <el-select v-model="form.templateId" placeholder="请选择内容模板" >
            <el-option
              v-for="dict in templateDictionary"
              :key="dict.id"
              :label="dict.templateTheme"
              :value="dict.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务类型" v-if="userPost == 'section_chief' && (taskTypeFlag ==2 || taskTypeFlag ==3)">
          <el-select v-model="form.checkType" placeholder="请选择任务类型"  >
            <el-option label="人员选择" value="1" />
            <el-option label="科室任务" value="2" />
          </el-select>
        </el-form-item>
        <el-form-item label="执行人员" prop="taskObjectIds" v-if=" userPost !=undefined && (userPost != 'director' &&form.checkType == 1) || (userPost == 'section_chief' && taskTypeFlag == 1)">
          <el-table  ref = "multiplePeopleTable" :data="peopleDictionary" :show-header="false" @selection-change="handleSelectionPeopleChange">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="执行人员" align="center" prop="userName"/>
            <el-table-column label="选择企业" align="center" >
              <template slot-scope="scope">
            <el-button v-if="taskTypeFlag != 1 " @click ="assignStation(scope.row)">点击选择</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" v-if="showSubmitButton()" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--处长 双随机或周期选择检查对象 弹框-->
    <el-dialog :title ="directorForm.title" :visible.sync="directorForm.open" width="500px" append-to-body>
      <el-table v-loading="directorForm.loading" ref = "multipleTable" :data="directorForm.list" :show-header="false" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="区名" align="center" prop="areaName"/>
        <el-table-column label="当前区域场站数" align="center" prop="count">
        <template slot-scope="scope">
          <span>{{scope.row.count}}家</span>
        </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" v-if="showSubmitButton()" @click="submitDirectorForm">确 定</el-button>
        <el-button @click="directorFormCancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--处长特定任务 或科长周期任务 任务对象选择 弹框-->
    <el-dialog :title ="companyForm.title" :visible.sync="companyForm.open" class="teding-dialog" width="800px" append-to-body>
      <el-form :model="queryCompanyParams" ref="queryForm" :inline="true" label-width="68px">
        <el-form-item label="企业名称" prop="companyName">
          <el-input
            v-model="queryCompanyParams.stationName"
            placeholder="请输入企业名称"
            clearable
            size="small"
            @keyup.enter.native="handleQueryCompany"
          />
        </el-form-item>
        <el-form-item label="所属区域" prop="taskTheme">
          <el-select v-model="queryCompanyParams.areaCode" placeholder="请选择所属区域">
            <el-option
              v-for="dict in areaPublishDictionary"
              :key="dict.areaCode"
              :label="dict.areaName"
              :value="dict.areaCode">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryCompany">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="companyForm.loading" ref = "multipleCompanyTable" :data="companyForm.list"  @selection-change="handleSelectionChangeForSpecial">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="企业名称" align="center" prop="stationName"/>
        <el-table-column label="地址" align="center" prop="address"/>
          <el-table-column label="所属区域" align="center" prop="belongName"/>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" v-if="showSubmitButton()" @click="submitSpecialForm">确 定</el-button>
        <el-button @click="specialCompanyFormCancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--分配员工场站 特定任务或周期任务 任务对象选择 弹框-->
    <el-dialog :title ="staffForm.title" :visible.sync="staffForm.open"  :before-close="handleStaffDialogClose" append-to-body>
      <el-form :model="queryStaffCompanyParams" ref="queryForm" :inline="true" label-width="68px">
        <el-form-item label="企业名称" prop="companyName">
          <el-input
            v-model="queryStaffCompanyParams.stationName"
            placeholder="请输入企业名称"
            clearable
            size="small"
            @keyup.enter.native="handleQueryCompany"
          />
        </el-form-item>
        <el-form-item label="所属区域" prop="taskTheme">
          <el-select v-model="queryStaffCompanyParams.areaCode" placeholder="请选择所属区域">
            <el-option
              v-for="dict in areaPublishDictionary"
              :key="dict.areaCode"
              :label="dict.areaName"
              :value="dict.areaCode">
            </el-option>
          </el-select>
        </el-form-item>,
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="searchStaffCompany">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetStaffQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table  ref = "multipleTable" :data="staffForm.deptShowedCompanyList"  @selection-change="handleSelectionStaffChange">
        <el-table-column  :selectable="selectEnable" type="selection" width="55" align="center" />
        <el-table-column label="企业名称" align="center" prop="stationName"/>
        <el-table-column label="地址" align="center" prop="address"/>
        <el-table-column label="所属区域" align="center" prop="belongName"/>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" v-if="showSubmitButton" @click="submitStaffForm">确 定</el-button>
        <el-button @click="staffFormCancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--特定任务 任务对象选择 弹框-->
    <el-dialog :title ="specialTaskForm.title" :visible.sync="specialTaskForm.open" class="teding-dialog" width="800px" append-to-body>
      <el-form :model="queryCompanyParams" ref="queryForm" :inline="true" label-width="68px">
        <el-form-item label="企业名称" prop="companyName">
          <el-input
            v-model="queryCompanyParams.stationName"
            placeholder="请输入企业名称"
            clearable
            size="small"
            @keyup.enter.native="handleQuerySpecialCompany"
          />
        </el-form-item>
        <el-form-item label="所属区域" >
          <el-select v-model="queryCompanyParams.areaCode" placeholder="请选择所属区域">
            <el-option
              v-for="dict in areaPublishDictionary"
              :key="dict.areaCode"
              :label="dict.areaName"
              :value="dict.areaCode">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuerySpecialCompany">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetSpecialQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="specialTaskForm.loading" ref = "multipleCompanyTable" :data="specialTaskForm.list"  @selection-change="handleSelectionChangeForSpecial">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="企业名称" align="center" prop="stationName"/>
        <el-table-column label="地址" align="center" prop="address"/>
        <el-table-column label="所属区域" align="center" prop="belongName"/>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" v-if="showSpecialSubmitButton()" @click="submitSpecialForm">确 定</el-button>
        <el-button @click="specialCompanyFormCancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listInformation, getInformation, delInformation, addInformation, updateInformation, exportInformation,getDirectorAreaList ,userPost,areaList,getCompanyList,getRandomList,getTemplateList,getDeptUserList,getCheckedCompanyListFromDB,getUserId,getValidateCheckResult,getZqCompanyList} from "@/api/task/information";

export default {
    name: "Information",
    data() {
        return {
          //页面显示状态
           pageShowStatus:false,
           //全部时间选择状态
            timeStatusList:[
              {status:0,text:"全部"},
              {status:1,text:"本周"},
              {status:2,text:"本月"},
              {status:3,text:"本年"}
            ],
            //选中的时间状态
            timeStatus:1,
            //全部状态
            statusList:[
              {status:0,text:"全部"},
              {status:1,text:"待办"},
              {status:2,text:"进行中"},
              {status:3,text:"已完成"},
              {status:4,text:"超期"}
            ],
            //选中的状态
            status:1,
             //全部来源状态
            originStatusList:[
              {status:0,text:"全部"},
              {status:1,text:"我发起的"},
              {status:2,text:"我处理的"}
            ],
             //选中的来源状态
            originStatus:0,
            //开始时间结束时间状态
            startTimeStatusList:[
              {status:1,text:"开始时间正序"},
              {status:2,text:"开始时间倒序"},
              {status:3,text:" 结束时间正序"},
               {status:4,text:" 结束时间倒序"}
            ],
            //选中的时间排序状态
            startStatus:1,
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            //选中数组的数量（区域数）
            areaNums: [],
            //选中的人员id
            peopleIds: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            //显示标识 处长 1-显示区域选择 2-显示企业选择
            changeViewFlag: 1,
            //全局任务类型标识 1-双随机 2-周期 3-特定
            taskTypeFlag: 0,
            // 总条数
            total: 0,
            //当前人员的岗位 director -处长 section_chief -科长 section_member -科员
            userPost: "0",
            // 主任务信息表格数据
            informationList: [],
            // 任务类型字典
            taskPublishType: [],
            //科员用的任务类型字典
            memberPublishType:[],
            //任务状态字典
            taskPublishStatus: [],
            //区域名称字典
            areaPublishDictionary: [],
            //规则名称字典
            ruleDictionary: [],
            //内容模板名称字典
            templateDictionary: [],
            //人员名称字典
            peopleDictionary: [],
            //是否自己发起的任务标识位Y-是 N-否
            createByOwnFlag:"",
            //userId 科员
            memberUserId:0,
            //提交前校验随机规则结果 Y-正常 N有错误 NULL-当前任务不存在
            validateCheckResult:"",
            //多选框暂存数据，待确定时存值
            selectionSave:{},
            //时间选择框限制
            pickerOptions:{
                disabledDate(time) {
                    return time.getTime() <= Date.now() - 24 * 60 * 60 * 1000
                }
            },



            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            //是否disable (科长和科员级别)
            isActionDisable: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 18,
                taskType: undefined,
                taskTheme: undefined,
                startDate: undefined,
                endDate: undefined,
                taskDescribe: undefined,
                taskObjectAreas: undefined,
                taskObjectIds: undefined,
                taskStatus: undefined,
                completionTime: undefined,
                userId: undefined,
                deptId: undefined,
                postCode: undefined,
                updateId: undefined,
                originStatus:undefined,
                status:undefined,
                timeStatus:undefined,
                startStatus:undefined,
            },
            queryCompanyParams: {
                pageNum: 1,
                pageSize: 18,
                stationName: undefined,
                areaCode: undefined,

            },
            queryStaffCompanyParams: {
                stationName: undefined,
                areaCode: undefined,
            },
            directorForm: {
                title: "",
                open: false,
                loading: true,
                list: [],
            },
            companyForm: {
                title: "",
                open: false,
                loading: true,
                list: [],
            },
            randomForm: {
                title: "",
                open: false,
                loading: true,
                list: [],
            },
            staffForm: {
                title: "",
                open: false,
                loading: true,
                //科长分配员工展示的list 查询时展示
                deptShowedCompanyList: [],
                //分配时选中的list
                deptCheckedList: [],
                //科长选中的list
                deptAllCompanyList: [],
                //查询时用于塞值的list
                deptSaveValueList: [],
                //点击选择时，当前的userId
                staffUserId: undefined,
                //当前用户所对应的被分配的企业及userId 实体类
                userStation: {},
                //当前用户所对应的勾选的list
            },
            specialTaskForm:{
              title:"",
              open:false,
              loading:true,
                list:[],
            },
            joinAreaCodeStr: "",
            checkedAreaCodes: [],
            joinCompanyIdStr: "",
            checkedCompanyIds: [],
            checkedRuleIds: [],
            checkedUserIds: [],
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                userId: [
                    {required: true, message: "任务发布人id不能为空", trigger: "blur"}
                ],
                deptId: [
                    {required: true, message: "任务发布人部门id不能为空", trigger: "blur"}
                ],
                postCode: [
                    {required: true, message: "任务发布人岗位code不能为空", trigger: "blur"}
                ],
                taskTheme: [{required: true, message: "任务主题不能为空", trigger: "blur"}],
                taskType: [{required: true, message: "任务类型不能为空", trigger: "blur"}],
                startDate: [{required: true, message: "任务开始日期不能为空", trigger: "blur"}],
                endDate: [{ message: "任务结束日期不能为空", trigger: "blur"}],
            }
        };
    },
    created() {
      if(this.$store.state.taskStatus && this.$store.state.taskStatus.taskstatus && this.$store.state.taskStatus.taskstatus!=0){
        this.status=this.$store.state.taskStatus.taskstatus
          this.timeStatus = 0
         this.$store.commit('setStatus',0)
      }else{
        this.status=1
      }
        this.queryParams.status=this.status
        this.queryParams.timeStatus = this.timeStatus
        this.queryParams.originStatus = this.originStatus;
       this.queryParams.startStatus = this.startStatus;
        this.getList();
        this.getUserPost();
        this.getAreaList();
        this.getRuleList();
        this.getTaskTemplateList();
        this.getPeopleList();
        this.receiveUserId();
        this.getDicts("task_publish_type").then(response => {
            this.taskPublishType = response.data;
        });

        this.getDicts("task_publish_status").then(response => {
            this.taskPublishStatus = response.data;
        });
    },
    methods: {
        /** 查询当前人员的岗位*/
        getUserPost() {
            userPost().then(response => {
                this.userPost = response.data;
                console.log(this.userPost);
            });
        },
        /** 查询主任务信息列表 */
        getList() {
            this.loading = true;
            listInformation(this.queryParams).then(response => {
                this.informationList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        /** 查询区域列表*/
        getAreaList() {
            areaList().then(response => {
                this.areaPublishDictionary = response.data;
            });
        },
        //查询规则
        getRuleList() {
            getRandomList().then(response => {
                this.ruleDictionary = response.data;
            });
        },
        //查询内容
        getTaskTemplateList() {
            getTemplateList().then(response => {
                this.templateDictionary = response.data;
            });
        },
        //查询人员姓名
        getPeopleList() {
            getDeptUserList().then(response => {
                this.peopleDictionary = response.data;
            });
        },
        //科员需要查询自己的userId
        receiveUserId(){
          getUserId().then(response => {
              this.memberUserId = response.data;
          });
        },
        // 取消按钮
        cancel() {
            this.open = false;
            if (this.$refs != undefined && this.$refs.multiplePeopleTable != undefined) {
                this.$refs.multiplePeopleTable.clearSelection();
            }
            this.reset();
        },
        handleDialogClose() {
            if (this.$refs != undefined && this.$refs.multiplePeopleTable != undefined) {
                this.$refs.multiplePeopleTable.clearSelection();
            }
            this.open = false;
            this.reset();

        },
        // 表单重置
        reset() {
            this.form = {
                id: undefined,
                taskType: undefined,
                taskTheme: undefined,
                startDate: undefined,
                endDate: undefined,
                taskDescribe: undefined,
                taskObjectAreas: undefined,
                taskObjectIds: undefined,
                taskStatus: "1",
                completionTime: undefined,
                userId: undefined,
                deptId: undefined,
                postCode: undefined,
                delFlag: undefined,
                createTime: undefined,
                updateTime: undefined,
                updateId: undefined,
                remark: undefined,
                taskObjectAreasNum: undefined,
                ruleId: undefined,
                peopleId: [],
                templateId: undefined,
                //展示科室任务或人员选择标识 1-科室任务 2-人员选择
                checkType: undefined,
                deptAllCompanyList:[],
                checkedCompanyIds:[],
            };
        },
        resetStaffForm(){
            this.staffForm= {
                title: "",
                    open: false,
                    loading: true,
                    //科长分配员工展示的list 查询时展示
                    deptShowedCompanyList: [],
                    //分配时选中的list
                    deptCheckedList: [],
                    //科长选中的list
                    deptAllCompanyList: [],
                    //查询时用于塞值的list
                    deptSaveValueList: [],
                    //点击选择时，当前的userId
                    staffUserId: undefined,
                    //当前用户所对应的被分配的企业及userId 实体类
                    userStation: {},
                //当前用户所对应的勾选的list
            };
            },
        resetQueryCompanyParam() {
            this.queryCompanyParams = {
                pageNum: 1,
                pageSize: 18,
                stationName: undefined,
                areaCode: undefined,
            };
        },
        resetStaffQueryCompanyParam() {
            this.queryStaffCompanyParams = {
                stationName: undefined,
                areaCode: undefined,
            };
        },
        /** 搜索公司按钮操作 */
        handleQueryCompany() {
            this.queryParams.pageNum = 1;
            this.companyForm.loading = true;
            getCompanyList(this.queryCompanyParams).then(response => {
                this.companyForm.list = response.data;
                this.companyForm.loading = false;
            });
        },
        /** 特定任务搜索公司按钮操作 */
        handleQuerySpecialCompany() {
            this.specialTaskForm.loading = true;
            if(this.createByOwnFlag != "N"){
                getCompanyList(this.queryCompanyParams).then(response => {
                    this.specialTaskForm.list = response.data;
                    this.specialTaskForm.loading = false;
                });
                //非自己创建时，和初始化时一样，需要筛选
            }else if(this.createByOwnFlag == "N"){
                getCompanyList(this.queryCompanyParams).then(response => {
                    this.specialTaskForm.list = response.data;
                    this.specialTaskForm.list = this.specialTaskForm.list.filter(item=>this.checkedCompanyIds.indexOf(item.stationId) >=0);

                    this.specialTaskForm.loading = false;
                });
            }

        },
        //分配企业时的页面查询方法
        searchStaffCompany() {
            this.staffForm.deptSaveValueList=[];
            this.staffForm.deptAllCompanyList.filter(item => {

                if (this.queryStaffCompanyParams.stationName != null && this.queryStaffCompanyParams.stationName != undefined && this.queryStaffCompanyParams.stationName != ""
                    && this.queryStaffCompanyParams.areaCode != null && this.queryStaffCompanyParams.areaCode != undefined && this.queryStaffCompanyParams.areaCode != "") {
                    if (item.stationName.includes(this.queryStaffCompanyParams.stationName) && item.areaCode.includes(this.queryStaffCompanyParams.areaCode)) {
                        this.staffForm.deptSaveValueList.push(item);
                    }
                } else if (this.queryStaffCompanyParams.stationName != null && this.queryStaffCompanyParams.stationName != undefined && this.queryStaffCompanyParams.stationName != "") {
                    if (item.stationName.includes(this.queryStaffCompanyParams.stationName)) {
                        this.staffForm.deptSaveValueList.push(item);
                    }
                } else if (this.queryStaffCompanyParams.areaCode != null && this.queryStaffCompanyParams.areaCode != undefined && this.queryStaffCompanyParams.areaCode != "") {
                    if (item.areaCode.includes(this.queryStaffCompanyParams.areaCode)) {
                        this.staffForm.deptSaveValueList.push(item);
                    }
                }else{
                    this.staffForm.deptSaveValueList.push(item);
                }
            })
            this.staffForm.deptShowedCompanyList = this.staffForm.deptSaveValueList;
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetQueryCompanyParam();
            this.handleQueryCompany();
        },
        //特定任务重置按钮
        resetSpecialQuery(){
          this.resetQueryCompanyParam();
          this.handleQuerySpecialCompany();
        },
        /** 重置按钮操作 */
        resetStaffQuery() {
            this.resetStaffQueryCompanyParam();
            this.searchStaffCompany();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.areaCode)
            this.areaNums = selection.map(item => item.count)
            this.single = selection.length != 1
            this.multiple = !selection.length
        },
        //周期任务 多选框选中数据
        handleSelectionChangeForSpecial(selection) {
            this.ids = selection.map(item => item.stationId)
            if(this.userPost != 'director'){
                this.staffForm.deptAllCompanyList = selection.map(item => item)
            }
            this.single = selection.length != 1
            this.multiple = !selection.length
        },
        //双随机任务 规则选中数据

        handleSelectionPeopleChange(selection) {
            this.peopleIds = selection.map(item => item.userId)
            this.single = selection.length != 1
            this.multiple = !selection.length
        },
        //科长给员工分配企业时的多选
        handleSelectionStaffChange(selection) {
            //需要暂存一下，然后在确认时，才去操作

            this.selectionSave = selection;
            // this.staffForm.deptCheckedList = selection.map(item => {
            //     if(item.userId != null && item.userId !=undefined && item.userId !="" && item.userId == this.staffForm.staffUserId){
            //         item.userId = "";
            //     }
            //     return item;
            // })
        },
        //因为给员工分配企业的多选触发事件只是存值，需要在确定时，进行处理
        handleChiefSubmit(){
            this.staffForm.deptCheckedList = this.selectionSave.map(item => {
                if(item.userId != null && item.userId !=undefined && item.userId !="" && item.userId == this.staffForm.staffUserId){
                    item.userId = "";
                }
                return item;
            })
        },
        selectEnable(row,index) {
            if (row.userId != "" && row.userId != null && row.userId != undefined && this.staffForm.staffUserId != row.userId ) {
                return false;//当勾选用户id不相等时，禁用 (如果userId没有值，即当前还未勾选时，不需要禁用)
            } else {
                return true;
            }
        },
        //筛选任务类型
        filterPublishType(){
            this.memberPublishType = this.taskPublishType;
            if(this.userPost == "section_member"){
                this.memberPublishType = this.taskPublishType.filter(item=>item.dictLabel =="特定任务");
            }
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.resetStaffForm();
            this.taskTypeFlag = 0;
            this.filterPublishType();
            this.checkedAreaCodes = [];
            this.checkedCompanyIds = [];
            this.changeDisableStatus("add");
            this.open = true;
            this.title = "发布任务";
            this.createByOwnFlag = undefined;
            this.getSpecialCompanyList();
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.reset();
            this.filterPublishType();
            this.checkedAreaCodes = [];
            this.resetStaffForm();
            this.changeDisableStatus("update");
            const id = row.id || this.ids
            getInformation(id).then(response => {
                this.form = response.data;
                this.open = true;
                this.title = "补全任务信息";
                this.changeView();
                this.splitCheckUserIds();
                this.splitAreaCodes();
                this.splitStationIds();
                this.createByOwnFlag = this.form.createByOwnFlag;
                this.getSpecialCompanyList();
                // this.getZhouqiCompanyList(id);
            });
        },
        //提交前校验
        validateBeforeSubmit(){
            if(this.form.startDate>this.form.endDate){
                this.msgError("开始时间不能超过结束时间，请重新选择！");
                return false;
            }
            if(this.form.formStatusCount !="0" && this.form.formStatusCount!=null && this.form.formStatusCount!=undefined && this.form.postCode !=null && this.form.postCode != undefined){
                this.msgError("已经分配过的任务不能进行更改 ！");
                return false;
            }
            if(this.userPost == "director"){
                if(!this.form.taskType && this.form.taskType != 0){
                    this.msgError("请选择任务类型！");
                    return false;
                }
                if((this.taskTypeFlag == 1 || this.taskTypeFlag == 2) && (!this.form.taskObjectAreas || this.form.taskObjectAreas =='')){
                    this.msgError("请至少选择一个任务对象！");
                    return false;
                }
                if(this.taskTypeFlag == 3 && (!this.form.taskObjectIds || this.form.taskObjectIds=='')){
                    this.msgError("请至少选择一个任务对象！");
                    return false;
                }
            }
            if(this.userPost == "section_chief"){
                if(!this.form.taskType && this.form.taskType != 0){
                    this.msgError("请选择任务类型！");
                    return false;
                }
                if(this.taskTypeFlag == 1 ){
                    if(!this.form.ruleId || this.form.ruleId == ''){
                        this.msgError("请选择随机规则!");
                        return false;
                    }
                    if(!this.form.templateId || this.form.templateId ==''){
                        this.msgError("请选择内容模板！");
                        return false;
                    }
                    if(!this.peopleIds || this.peopleIds == null || this.peopleIds.length == 0){
                        this.msgError("请选择执行人员!");
                        return false;
                    }
                }
                if(this.taskTypeFlag == 2){
                    if(!this.form.templateId || this.form.templateId ==''){
                        this.msgError("请选择内容模板！");
                        return false;
                    }
                    if(!this.form.checkType || this.form.checkType ==''){
                        this.msgError("请选择任务类型！");
                        return false;
                    }
                }
                if(this.taskTypeFlag == 3){
                    if(!this.form.checkType || this.form.checkType ==''){
                        this.msgError("请选择任务类型！");
                        return false;
                    }
                }
            }
            //当为科员时，将本人的userId放入到list中，作为检查人员id
            if(this.userPost == "section_member"){
                if(!this.form.taskType && this.form.taskType != 0 ){
                    this.msgError("请选择任务类型！");
                    return false;
                }
                this.staffForm.deptAllCompanyList.forEach(detail => {
                    detail.userId = this.memberUserId;
                })
            }
            if((this.userPost == "section_chief"|| this.userPost =="section_member") && (this.taskTypeFlag == 2|| this.taskTypeFlag == 3) && this.staffForm.deptAllCompanyList.length == 0){
                this.msgError("请至少选择一个任务对象！");
                return false;
            }
            if(this.userPost != "section_member" && this.form.checkType != 2 &&!this.validateStaffTaskNum()){
                this.msgError("请检查选择的任务对象是否全部分配完成");
                return false;
            }
            if(this.userPost == "section_chief" && !this.validateCheck()){
                return false;
            }
            return true;
        },
        /** 提交按钮 */
        submitForm: function () {
            if(!this.validateBeforeSubmit()){
                return;
            }
            this.form.postCode = this.userPost;
            this.form.peopleId = this.peopleIds;
            this.form.deptAllCompanyList = this.staffForm.deptAllCompanyList;
            this.$refs["form"].validate(valid => {
                if (valid) {
                    if (this.form.id != undefined) {
                        updateInformation(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess("修改成功");
                                this.open = false;
                                this.getList();
                            }
                        });
                    } else {
                        addInformation(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess("新增成功");
                                this.open = false;
                                this.getList();
                            }
                        });
                    }
                }
            });
        },
        //提交前校验勾选的人员是否匹配了所有的科长选择的场站
        validateStaffTaskNum(){
            var countNum = 0;
            this.staffForm.deptAllCompanyList.forEach(detail => {
                if(this.peopleIds.indexOf(detail.userId) >=0){
                    countNum++;
                }
            })
            if(countNum != this.staffForm.deptAllCompanyList.length){
                return false;
            }else{
                return true;
            }
        },
        async validateCheck(){
            await getValidateCheckResult(this.form).then(response => {
                this.validateCheckResult = response.data;
                if(this.validateCheckResult == 'N'){
                    this.msgError("当前企业数量无法满足该随机模板，请检查！")
                    return false;
                }
                if(this.validateCheckResult == 'NULL'){
                    this.msgError("当前任务不存在，请检查是否还存在该任务！")
                    return false;
                }
            });
            return true;
        },
        /** 详情按钮操作 */
        handleView(row) {
            this.reset();
            const taskId = row.id
            this.$router.push({
                path:"/taskk/index",
                query:{
                    taskId:taskId
                }
            })
            console.log(this.$router);
            // getWaybill(waybillId).then(response => {
            //   this.form = response.data;
            //   this.open = true;
            //   this.title = "运单详情";
            // });
        },
        /** 删除按钮操作 */
        handleDelete(row) {
            const ids = row.id || this.ids;
            this.$confirm('是否确认删除主任务信息编号为"' + ids + '"的数据项?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                return delInformation(ids);
            }).then(() => {
                this.getList();
                this.msgSuccess("删除成功");
            }).catch(function () {
            });
        },
        validateBeforeClick() {
            if (this.form.taskType == null || this.form.taskType == undefined) {
                this.msgError("选择对象前，请先确定任务类型！");
                return false;
            } else {
                return true;
            }
        },
        /*选择对象*/
        async chooseObject() {
            if (this.validateBeforeClick()) {
                if (this.changeViewFlag == 1) {
                    await getDirectorAreaList().then(response => {
                        this.directorForm.list = response.data;
                        this.directorForm.open = true;
                        this.directorForm.title = "选择检查对象";
                        this.directorForm.loading = false;
                    });
                    if (this.checkedAreaCodes.length != 0) {
                        this.directorForm.list.forEach(area => {
                            if (this.checkedAreaCodes.indexOf(area.areaCode) >= 0) {
                                this.$refs.multipleTable.toggleRowSelection(area, true);
                            }
                        })
                    }
                } else if (this.changeViewFlag == 2) {
                    this.resetQueryCompanyParam();
                    await getCompanyList(this.queryCompanyParams).then(response => {
                        this.companyForm.list = response.data;
                        this.companyForm.open = true;
                        this.companyForm.title = "选择检查对象";
                        this.companyForm.loading = false;
                    });
                    if (this.checkedCompanyIds.length != 0) {
                        this.companyForm.list.forEach(company => {
                            //因为split出来的数组是字符类型
                            if (this.checkedCompanyIds.indexOf(company.stationId) >= 0 || this.checkedCompanyIds.indexOf(company.stationId.toString()) >= 0) {
                                this.$refs.multipleCompanyTable.toggleRowSelection(company, true);
                            }
                        })
                    }
                    //当点击人员的选择分配场站时，去数据库查询详情表，看对应的userId和stationId的对象list，只需要查一次，因为下面的勾选是根据userId来的
                    if(this.staffForm.deptCheckedList.length == 0 && this.userPost !='director'){
                        this.selectcheckedCompanyFromDB();
                    }
                }
            }
        },
/*        //周期任务需要去view表获取勾选的数据
        async getZhouqiCompanyList(id){
            if(this.userPost !='director' && this.taskTypeFlag == 2){
                await getZqCompanyList(id).then(response => {
                    var str = response.data;
                    console.log(str);
                    if(str){
                        this.checkedCompanyIds = str.split(",");
                    }else{
                        this.checkedCompanyIds = [];
                    }
                });
            }
        },*/
        //特定任务初始化时，需要获取已选择企业的长度，所以要重复查询一次数据库
        async getSpecialCompanyList(){
            if(this.userPost !='director' ){
                this.resetQueryCompanyParam();
                if(this.createByOwnFlag == "N"){
                    await getCompanyList(this.queryCompanyParams).then(response => {
                        this.specialTaskForm.list = response.data;
                        this.specialTaskForm.list = this.specialTaskForm.list.filter(detail =>this.checkedCompanyIds.indexOf(detail.stationId.toString()) >=0);
                        this.staffForm.deptAllCompanyList = this.specialTaskForm.list;
                    });
                }else{
                    await getCompanyList(this.queryCompanyParams).then(response => {
                        this.specialTaskForm.list = response.data;
                    });
                }
            }
        },
        //特定任务选择对象 单独写一个dialog
        async chooseSpecialObject(){
            this.resetQueryCompanyParam();
            if(this.createByOwnFlag == "N"){
                // await getCompanyList(this.queryCompanyParams).then(response => {
                //     this.specialTaskForm.list = response.data;
                //     this.specialTaskForm.list = this.specialTaskForm.list.filter(detail =>this.checkedCompanyIds.indexOf(detail.stationId.toString()) >=0);
                //     this.specialTaskForm.open = true;
                //     this.specialTaskForm.title = "选择检查对象";
                //     this.specialTaskForm.loading = false;
                // });
                this.specialTaskForm.open = true;
                this.specialTaskForm.title = "选择检查对象";
                this.specialTaskForm.loading = false;
            }else{
                // await getCompanyList(this.queryCompanyParams).then(response => {
                //     this.specialTaskForm.list = response.data;
                //     this.specialTaskForm.open = true;
                //     this.specialTaskForm.title = "选择检查对象";
                //     this.specialTaskForm.loading = false;
                // });
                this.specialTaskForm.open = true;
                this.specialTaskForm.title = "选择检查对象";
                this.specialTaskForm.loading = false;
            }
            this.$nextTick(() => {
            if (this.checkedCompanyIds.length != 0) {
                this.specialTaskForm.list.forEach(company => {
                    //因为split出来的数组是字符类型
                    if (this.checkedCompanyIds.indexOf(company.stationId) >= 0 || this.checkedCompanyIds.indexOf(company.stationId.toString()) >= 0) {
                        this.$refs.multipleCompanyTable.toggleRowSelection(company, true);
                    }
                })
            }
            });
            //当点击人员的选择分配场站时，去数据库查询详情表，看对应的userId和stationId的对象list，只需要查一次，因为下面的勾选是根据userId来的
            if(this.staffForm.deptCheckedList.length == 0 && this.userPost !='director'){
                this.selectcheckedCompanyFromDB();
            }
        },
        async selectcheckedCompanyFromDB(){
            if(this.form.id != undefined && this.form.id !=null){
                await getCheckedCompanyListFromDB(this.form.id).then(response => {
                    this.staffForm.deptCheckedList = response.data;
                });
            }
            if(this.staffForm.deptCheckedList.length !=0){
                this.staffForm.deptCheckedList.forEach(checked=>{
                    this.staffForm.deptAllCompanyList.forEach(detail=>{
                        if(checked.stationId == detail.stationId){
                            detail.userId = checked.userId;
                        }
                    })
                })
            }

            this.staffForm.deptShowedCompanyList =this.staffForm.deptAllCompanyList;
        },
        submitDirectorForm() {
            this.directorForm.open = false;
            this.checkedAreaCodes = this.ids;
            this.joinAreaCodeStr = this.checkedAreaCodes.join(",");
            this.form.taskObjectAreas = this.joinAreaCodeStr;
            this.form.taskObjectAreasNum = 0;
            this.areaNums.forEach(num => {
                this.form.taskObjectAreasNum += num;
            });
            //特定任务的companyId需要清空
            if (this.userPost == "director") {
                this.form.taskObjectIds = "";
            }
        },
        submitSpecialForm() {
            this.companyForm.open = false;
            this.specialTaskForm.open = false;
            this.checkedCompanyIds = this.ids;
            this.joinCompanyIdStr = this.checkedCompanyIds.join(",");
            this.form.taskObjectIds = this.joinCompanyIdStr;
            //点击确定时，对应双随机，周期任务的区域code，需要清空
            if (this.userPost == "director") {
                this.form.taskObjectAreas = "";
                this.form.taskObjectAreasNum = undefined;
            }
        },
        handleStaffDialogClose(){
          //this.submitStaffForm();
/*            if (this.$refs != undefined && this.$refs.multiplePeopleTable != undefined) {
                this.$refs.multipleTable.clearSelection();   multipleTable
            }*/
            if (this.$refs != undefined && this.$refs.multiplePeopleTable != undefined) {
                this.$refs.multipleTable.clearSelection();
            }
            if(this.staffForm.deptCheckedList.length !=0){
                this.staffForm.deptCheckedList.forEach(checked=>{
                    this.staffForm.deptAllCompanyList.forEach(detail=>{
                        if(checked.stationId == detail.stationId){
                            detail.userId = checked.userId;
                        }
                    })
                })
            }
            this.staffForm.deptShowedCompanyList =this.staffForm.deptAllCompanyList;
            this.staffForm.open = false;
        },
        staffFormCancel(){
            if (this.$refs != undefined && this.$refs.multiplePeopleTable != undefined) {
                this.$refs.multipleTable.clearSelection();
            }
            if(this.staffForm.deptCheckedList.length !=0){
                this.staffForm.deptCheckedList.forEach(checked=>{
                    this.staffForm.deptAllCompanyList.forEach(detail=>{
                        if(checked.stationId == detail.stationId){
                            detail.userId = checked.userId;
                        }
                    })
                })
            }
            this.staffForm.deptShowedCompanyList =this.staffForm.deptAllCompanyList;
            this.staffForm.open = false;
        },
        submitStaffForm() {
            this.handleChiefSubmit();
            this.staffForm.open = false;
            this.ids = [];
            this.staffForm.deptCheckedList.forEach(detail => {
                this.ids.push(detail.stationId);
            })
            this.staffForm.deptAllCompanyList.forEach(detail => {
                if(this.ids.indexOf(detail.stationId) == -1 && detail.userId == this.staffForm.staffUserId){
                    detail.userId = "";
                }
            })
            this.staffForm.deptCheckedList.forEach(item => {
                this.staffForm.deptAllCompanyList.forEach(detail => {
                    if (item.stationId == detail.stationId && (detail.userId == null || detail.userId == undefined || detail.userId =="")) {
                        detail.userId = this.staffForm.staffUserId;
                    }
                })
            })
            this.staffForm.deptShowedCompanyList = this.staffForm.deptAllCompanyList;

        },
        async assignStation(row) {
            if(this.staffForm.deptAllCompanyList.length == 0){
                this.msgError("请先选择任务对象");
                return ;
            }
            this.staffForm.open = true;
            this.staffForm.title = "分配场站";
            this.staffForm.staffUserId = row.userId;
            this.$nextTick(() => {
                if (this.staffForm.deptAllCompanyList.length != 0) {
                    this.staffForm.deptAllCompanyList.forEach(detail => {
                        if (detail.userId) {
                            this.$refs.multipleTable.toggleRowSelection(detail, true);
                        }
                    })
                }
            });
            this.staffForm.deptShowedCompanyList = this.staffForm.deptAllCompanyList;


        },
        directorFormCancel() {
            this.directorForm.open = false;
        },
        specialCompanyFormCancel() {
            this.companyForm.open = false;
            this.specialTaskForm.open = false;
        },
        //取消有问题，在分配页面处关闭取消按钮
        specialStaffCancel() {
            this.staffForm.open = false;
        },
        // 类型字典翻译
        typeFormat(row, column) {
            return this.selectDictLabel(this.taskPublishType, row.taskType);
        },
        // 状态字典翻译
        statusFormat(row, column) {
            return this.selectDictLabel(this.taskPublishStatus, row.taskStatus);
        },
        // 非处长状态字典翻译
        formStatusFormat(row, column) {
            return this.selectDictLabel(this.taskPublishStatus, row.formStatus);
        },
        changeView() {
            if ((this.form.taskType == 3 && this.userPost == "director") || (this.userPost == "section_chief" && this.form.taskType == 2)) {
                this.changeViewFlag = 2;
            } else if ((this.form.taskType == 1 || this.form.taskType == 2) && this.userPost == "director") {
                this.changeViewFlag = 1;
            }
            this.taskTypeFlag = this.form.taskType;
            this.ids = [];
            this.checkedCompanyIds = [];
        },
        changeDisableStatus(str) {
            if (this.userPost == "director") {
                this.isActionDisable = false;
            } else if (this.userPost == "section_chief") {
                if (str == "add") {
                    this.isActionDisable = false;
                } else if (str == "update") {
                    this.isActionDisable = true;
                }
            }
        },
        isHandleDisable(row){
            if(this.userPost == 'director'){
                if(row.taskStatus != 1){
                    return true;
                }
            }else if(this.userPost !='director'){
                if(row.formStatus != 1){
                    return true;
                }
            }
            return false;
        },
        splitCheckUserIds() {
            if (this.form.checkUserIds != null && this.form.checkUserIds != undefined && this.form.checkUserIds != "") {
                this.checkedUserIds = this.form.checkUserIds.split(",");
                this.$nextTick(() => {
                    this.peopleDictionary.forEach(people => {
                        if (this.checkedUserIds.indexOf(people.userId.toString()) >= 0) {
                            this.$refs.multiplePeopleTable.toggleRowSelection(people, true);
                        }
                    });
                });
            }
        },
        splitAreaCodes() {
            if (this.form.taskObjectAreas != null && this.form.taskObjectAreas != undefined && this.form.taskObjectAreas != "") {
                this.checkedAreaCodes = this.form.taskObjectAreas.split(",");
            }
        },
        splitStationIds() {
            if (this.form.taskObjectIds != null && this.form.taskObjectIds != undefined && this.form.taskObjectIds != "") {
                this.checkedCompanyIds = this.form.taskObjectIds.split(",");
            }
        },
        //处长查看科长的任务时，去除确定按钮
        showSubmitButton(){
             if(this.form.postCode !=this.userPost && this.userPost == "director" && this.form.postCode !=null && this.form.postCode != undefined){
                return false;
            }else if(this.userPost == "director" && this.form.taskStatus != '1'){
                 return false;
             }else{
                 return true;
             }
        },
        //特定任务 科长看处长任务时，去除确定按钮和取消按钮
        showSpecialSubmitButton(){
            if(this.createByOwnFlag == "N" && (this.userPost == "section_chief" || this.userPost == "section_member")){
                return false;
            }else{
                return true;
            }
        },

        /** ===========================================================================================*/
        /** 导出按钮操作 */
        handleExport() {
            const queryParams = this.queryParams;
            this.$confirm('是否确认导出所有主任务信息数据项?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                return exportInformation(queryParams);
            }).then(response => {
                this.download(response.msg);
            }).catch(function () {
            });
        },
         //时间状态选择切换
        timeStatusChange(status){
          this.timeStatus=status;
            this.queryParams.timeStatus = status;
            this.getList();

        },
        //状态选择切换
         statusChange(status){
          this.status=status;
          this.queryParams.status = status;
          this.getList();
        },
        //来源状态选择切换
         originStatusChange(status){
          this.originStatus=status;
          this.queryParams.originStatus = status;
             this.getList();
        },
        //开始时间结束时间正序倒叙切换
        startTimeStatusChange(status){
           this.startStatus=status;
            this.queryParams.startStatus = status;
            this.getList();
        },
        //页面显示状态切换
        pageShowStatusChange(){
          this.pageShowStatus=!this.pageShowStatus
        }
    }
  };

</script>
<style rel="stylesheet/scss" lang="scss">
  .selectComplainNumber{
    color:red;
    font-size:12px;
  }
 .allStatus{
   width:100%;
    .timeStatus{
      width:100%;
      border-bottom:1px dashed #ddd;
      display:flex;
      justify-content: flex-start;
      align-items: center;
      p{
        padding:0 20px;
        color:#000;
        cursor: pointer;
        font-size:13px;
      }
      p:nth-child(1){
        color:#8e8888;
        cursor: default;
      }
      p.active{
        color:#1890ff;
        font-weight: bold;
      }
    }
    border:1px solid #ddd;
    margin-bottom:30px;
    .originStatus{
      display:flex;
      justify-content: flex-end;
      align-items:center;
      .timeStatus{
         border:none;
      }
      .listStatus{
        display:flex;
        padding-right:20px;
        justify-content: flex-end;
        align-items: center;
        span{
          font-size:35px;
          margin-left:20px;
          cursor: pointer;
        }
        span:nth-child(1){
          background-color:#1890ff;
          color:#fff;
          border-radius:3px;
          padding:2px;
          font-size:23px;
        }
      }
    }
 }
  .informationList{
    padding:0!important;
    width:100%;
    margin:0!important;
    // display:flex;
    // justify-content: flex-start;
    // flex-wrap: wrap;
    p{
       text-overflow:ellipsis;
          white-space:nowrap;
          overflow:hidden;
    }
    .informationItem{
      padding:0!important;
      .box{
        // background:#f5f5f5;
        margin-right:10px;
        padding:10px;
        box-shadow: 2px 0 5px 2px #ddd;
        border-radius:10px;
      }
      box-sizing:border-box;

      //  width:250px;

      // margin-right:10px;
      font-size:14px;
      margin-bottom:10px;
      .informationItemTitle{
        b{
          text-overflow:ellipsis;
          white-space:nowrap;
          overflow:hidden;
        }
        display:flex;
        justify-content: space-between;
        align-items: center;
        color:#1890ff;
        font-weight: bold;
        .el-tag{
          border-radius:15px;
          height:20px;
          line-height:20px;
        }
      }
    }
  }
  .buttonColor{
     button:nth-child(1){
      color:#23c6ce
    }
    button:nth-child(2){
      color:#11b95c
    }
  }
  .teding-dialog{
    .el-dialog__body{
      max-height:500px!important;
      overflow: auto;
    }
  }
</style>
